[t:/]$ 지식_

libCurl의 커넥션 재활용..

2015/11/25

C개발자에겐 libCurl은 맥가이버 칼과 같다.

그런데, 고가용성/고성능을 구현하고자 할 때는 문제가 된다.
커넥션을 내부적으로 어떻게 다루는 지 제공된 API만으로는 알기 어렵다.

고성능을 구현하려면 최대한 keep-alive나 socket 자원을 효과적으로 활용해야 할 것이다.
NAT 밑에 들어간 server가 outbound 호출을 한다면 더욱 그렇다. (익명 다수 클라이언트 동접 상황의 원샷, 치고 빠지는 호출은 논외)

NAT에서는 변환용 포트 개수인 64K 이상 커넥션을 만들 수 없다.

우야뜬.. 이 문제 때문에 지금 서비스 중인 버전은 소켓레벨 http client를 그냥 만들어 쓰고 있다.

뭣 좀 찾다가 문서를 보니 libCurl이 커넥션 자원을 관리하고 있다는 것을 알았다.
세세한 튜닝 API는 지원하지 않는것 같다.

keep-alive 우선, 커넥션 재활용 우선.
기본은 5커넥션 유지, 설정은 바꿀 수 있음.

우야뜬 다음 배포는 이제는 거울 앞에선 내 누님같은 libCurl로 바꿔놓은 상태인데.. 최대 커넥션 수만 늘려놨다..

애초에 아무것도 몰랐다면 처음부터 libCurl로 개발했겠지.. ㅎㅎ

http://curl.haxx.se/docs/faq.html

— 이하 인용 —

5.6 What about Keep-Alive or persistent connections?

curl and libcurl have excellent support for persistent connections when transferring several files from the same server. Curl will attempt to reuse connections for all URLs specified on the same command line/config file, and libcurl will reuse connections for all transfers that are made using the same libcurl handle.

When you use the easy interface, the connection cache is kept within the easy handle. If you instead use the multi interface, the connection cache will be kept within the multi handle and will be shared among all the easy handles that are used within the same multi handle.





공유하기













[t:/] is not "technology - root". dawnsea, rss